I am using ABAddressBookRef as a reference for my device contacts.
this is my code that I am using in our app:
ABAddressBookRef phoneContacts = ABAddressBookCreate();
NSMutableArray *allContacts = [[[(NSArray*)ABAddressBookCopyArrayOfAllPeople (phoneContacts) autorelease] mutableCopy]autorelease];
[allContacts sortUsingFunction:(int (*)(id,id,void*)) ABPersonComparePeopleByName context:(void*)ABPersonGetSortOrdering()];
NSLog(@"No of Contacts:%i",[allContacts count]);
for(int i=0; i<[allContacts count]; i++)
{
ABRecordRef person = [allContacts objectAtIndex:i];
//get phone no fill phone no into array
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
if(multi!=NULL && ABMultiValueGetCount(multi)>0)
{
NSLog(@"Available");
} else {
NSLog(@"Not-Available");
}
}
But this returns 0 from [people count], while I have 10 contacts on my device.
I am not understanding what I am missing here.
Please help me.
Can you answer this question?
Answer
0 Answers